using System;
using System.Collections.Generic;
using System.Text;
using Rapier.Kodachi.Shared;
using System.Net;

namespace Rapier.Kodachi
{
    public static class Global
    {
        private static SystemImageList _SystemImageList = new SystemImageList(SystemImageListSize.extraLargeIcons);
        public static SystemImageList SystemImageList
        {
            get { return _SystemImageList; }
            set { _SystemImageList = value; }
        }

        public static string HttpPost(string uri, string parameters)
        {
            WebRequest req = WebRequest.Create(uri);
            //Add these, as we're doing a POST
            req.ContentType = "application/x-www-form-urlencoded";
            req.Method = "POST";
            //We need to count how many bytes we're sending. Post'ed Faked Forms should be name=value&
            byte[] bytes = System.Text.Encoding.ASCII.GetBytes(parameters);
            req.ContentLength = bytes.Length;
            System.IO.Stream os = req.GetRequestStream();
            os.Write(bytes, 0, bytes.Length); //Push it out there
            os.Close();
            WebResponse resp = req.GetResponse();
            if (resp == null) return null;
            System.IO.StreamReader sr = new System.IO.StreamReader(resp.GetResponseStream());
            return sr.ReadToEnd().Trim();
        }
    }
}
